<template>
  <div id="app">
  </div>
</template>
<script>
import socketIO from "socket.io-client";

export default {
  data() {
    return {
      socket: null,
      rybm: '',
      BMSAH: '',
    }
  },
  async mounted() {

  },
  methods: {
    async socketTest() {

      await this.connectSocket()
      let getUnitTreeList = await this.sendEvent("getUnitTreeList", "100000")
      console.log("getUnitTreeList", getUnitTreeList)

      let loginVerification = await this.sendEvent("loginVerification", {
        dwbm: '770000',
        dlbm: '王鹏',
        kl: '11111111',
      })
      console.log("loginVerification", loginVerification)
      this.rybm = loginVerification.GH

      let getUserInfoByCode = await this.sendEvent("getUserInfoByCode", {
        dwbm: '770000',
        rybm: this.rybm
      })
      console.log("getUserInfoByCode", getUserInfoByCode)


      let getCaseList = await this.sendEvent("getCaseList", {
        dwbm: '770000',
        rybm: this.rybm,
        gjc: "",
      })
      console.log("getCaseList", getCaseList)
      this.BMSAH = getCaseList[0].BMSAH

      let getCaseInfoByCode = await this.sendEvent("getCaseInfoByCode", this.BMSAH)
      console.log("getCaseInfoByCode", getCaseInfoByCode)


      let getEvidenceMaterialCatalog = await this.sendEvent("getEvidenceMaterialCatalog", {
        bmsah: this.BMSAH,
        dwbm: '770000'
      })
      console.log("getEvidenceMaterialCatalog", getEvidenceMaterialCatalog)

    },
    connectSocket() {
      return new Promise((resolve, reject) => {
        this.socket = socketIO("http://127.0.0.1:9011")
        this.socket.on('connect', resolve)
      })
    },
    sendEvent(eventName, data) {
      return new Promise((resolve, reject) => {
        this.socket.emit(eventName, data, resolve)
      })
    }
  }
}
</script>
<style lang="scss">
</style>
